import { createAlovaMockAdapter, type MockWrapper } from '@alova/mock'
import adapterFetch from 'alova/fetch'

const defaultHttpAdapter = adapterFetch()

const mockApis = import.meta.glob<MockWrapper>(['@/mock/**/*.ts', '!@/mock/_utils.ts'], {
  eager: true,
  import: 'default',
})
const mockList = []
for (const path in mockApis) {
  mockList.push(mockApis[path])
}

const mockAdapter = createAlovaMockAdapter(mockList, {
  httpAdapter: defaultHttpAdapter,
  delay: 1000,
  // onMockResponse: (res) => {
  //   const headers = new Headers(res.responseHeaders)
  //   const response = new Response(JSON.stringify(res.body), {
  //     status: res.status,
  //     statusText: res.statusText,
  //     headers,
  //   })

  //   return {
  //     response,
  //     headers,
  //   }
  // },
})

export { defaultHttpAdapter, mockAdapter }
